<template>
  <div class="weui-tab">
    <div class="weui-tab__panel">
      <slot>
      </slot>
    </div>
    <div class="weui-tabbar">
      <a href="javascript:;" class="weui-tabbar__item" v-for="(item, _index) in list"
         :class="{'weui-bar__item_on':_index==index}"
         @click="onClick(_index)">
        <!--<img src="./images/icon_tabbar.png" alt="" class="weui-tabbar__icon">-->
        <i :class="['weui-tabbar__icon', {'vux-reddot':item.has_dot}]" v-html="item.icon"
           style="font-size:24px;font-family:iconfont;font-style:normal;">
        </i>
        <p class="weui-tabbar__label" :style="{color:item.color}">{{item.label}}</p>
      </a>
    </div>
  </div>
</template>

<script>
  export default {
    props: {
      list: {
        type: Array,
        default() {
          return [{
            label: 'index',
            color: 'black'
          }, {
            label: 'word',
            color: 'red'
          }]
        }
      },
      index: {
        type: Number,
        default: 0
      }
    },
    methods: {
      onClick(index) {
        this.$emit('on-click', index)
      }
    }
  }
</script>

<style>
  @import '~weui/dist/style/weui.min.css';
</style>

<style scoped>
  .vux-reddot, .vux-reddot-border, .vux-reddot-s {
    position: relative;
  }

  .vux-reddot:after, .vux-reddot-border:after, .vux-reddot-s:after {
    content: '';
    position: absolute;
    display: block;
    width: 8px;
    height: 8px;
    background-color: #f74c31;
    border-radius: 5px;
    right: -3px;
    top: -3px;
    background-clip: padding-box;
  }

  .vux-reddot-border:before {
    content: '';
    position: absolute;
    display: block;
    width: 8px;
    height: 8px;
    background-color: #fff;
    border-radius: 5px;
    right: -4px;
    top: -4px;
    background-clip: padding-box;
    padding: 1px;
  }

  .vux-reddot-s:after {
    width: 6px;
    height: 6px;
    top: -5px;
    right: -5px;
  }
</style>
